﻿<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
    <script src="~/js/frame.js"></script>
</head>
<body>
    <div class="container-fluid">
        <form id="form">
            <div class="formrow">
                <div class="col-xs-12">
                    <div class="formtitle required">父级代码项</div>
                    <div class="formcontent">
                        <cloud-tree id="ParentItemGuid" url="tree" control-type="selectcode" select-type="single"></cloud-tree>
                    </div>
                </div>
            </div>
            <div class="formrow">
                <div class="col-xs-12">
                    <div class="formtitle required">代码文字</div>
                    <div class="formcontent">
                        <input name="ItemName" type="text" class="form-control required" placeholder="">
                    </div>
                </div>
            </div>
            <div class="formrow">
                <div class="col-xs-12">
                    <div class="formtitle required">代码值</div>
                    <div class="formcontent">
                        <input name="ItemValue" type="text" class="form-control required" placeholder="">
                    </div>
                </div>
            </div>
            <div class="formrow">
                <div class="col-xs-12">
                    <div class="formtitle">排序</div>
                    <div class="formcontent">
                        <input name="SortNum" type="text" class="form-control" placeholder="">
                    </div>
                </div>
            </div>
            <div style="display:none">
                <input name="ItemGuid" type="text" class="form-control" placeholder="">
                <input name="MainGuid" type="text" class="form-control" placeholder="">
                <input name="ParentItemGuid" type="text" class="form-control" placeholder="">
            </div>
            <div class="formbtnop">
                <button class="btn btn-primary cloudbtn" type="button" onclick="Save()"><span class="btntext">保 存</span></button>
                <button class="btn cloudbtn" type="button" onclick="Close()"><span class="btntext">关 闭</span></button>
            </div>
        </form>
    </div>
    <script>
        var validator = $("#form").validate();
        $(function () {
            LoadDetail();
        })
        function LoadDetail() {
            var param = { "ItemGuid": GetUrlParam("itemguid") }
            CloudPost(param, "opdetail", function (res) {
                if (res.code == 0) {
                    $("#form").SetForm(res.data);
                    $("#ParentItemGuid").attr("mainguid", res.data.MainGuid);
                    $("#ParentItemGuid").attr("selectvalue", res.data.ParentItemGuid);
                    RenderTree();
                }
            })
        }
        function Save() {
            if (validator.form()) {
                var param = $("#form").GetForm();
                param.ParentItemGuid = GetTreeSelectValue("ParentItemGuid")
                CloudPost(param, "opupdate", function (res) {
                    if (res.code == 0) {
                        OpenSuccess("保存成功！", function () {
                            CloseDialog();
                        })
                    } else {
                        OpenFail(res.data)
                    }
                })
            }
        }
        function Close() {
            CloseDialog();
        }
    </script>
</body>
</html>
